package cn.hfatec.shms.web.yk.ykGather.service;

import java.util.List;
import java.util.HashMap;


import cn.hfatec.shms.web.xc.xcJjbmx.model.XcJjbmxParams;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.yk.ykGather.model.YkGather;
import cn.hfatec.shms.web.yk.ykGather.dao.YkGatherDao;
import cn.hfatec.shms.web.yk.ykGather.model.YkGatherParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("YkGatherService")
public class YkGatherService {

    public static final String BEAN_ID = "YkGatherService";

    //注入Dao层
    @Resource(name = "YkGatherDao")
    private YkGatherDao ykGatherDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param ykGatherParams
     * @param page
     *
     */
    @Transactional
    public Table queryYkGatherTable(YkGatherParams ykGatherParams, Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("params", ykGatherParams);
        return baseDao.queryTableByPage("queryYkGather", params, page);
    }

    /**
     *
     * 插入数据
     * @param ykGather
     *
     */
    @Transactional
    public void saveYkGather(YkGather ykGather) {
        if(ykGather.getId() != null) {
            YkGather result = getYkGather(ykGather.getId());
            if(result != null) {
                ykGatherDao.update(ykGather);
            } else {
                ykGatherDao.insert(ykGather);
            }
        } else {
            ykGatherDao.insert(ykGather);
        }
    }

    /**
     *
     * 删除数据
     * @param id
     *
     */
    @Transactional
    public void deleteYkGather(Integer id) {

        ykGatherDao.delete(id);
    }

    /**
     *
     * 删除数据
     * @param ykGatherList
     *
     */
    @Transactional
    public void deleteYkGatherBatch(List<String> ykGatherList) {
        for(String id : ykGatherList) {
            deleteYkGather(Integer.valueOf(id));
        }
    }

    /**
     *
     * 根据ID获取数据
     * @param id
     *
     */
    @Transactional
    public YkGather getYkGather(Integer id) {

        return ykGatherDao.getYkGatherById(id);
    }


    /**
     *
     * 根据ID获取数据
     * @param billId
     *
     */
    @Transactional
    public void deleteYkGather(String  billId) {

        ykGatherDao.deleteYkGatherByBillId(billId);
    }

    /**
     *
     * 根据ID获取数据
     * @param ykGatherParams
     *
     */
    @Transactional
    public List getYkGatherList(YkGatherParams ykGatherParams) {

        return ykGatherDao.queryYkGather(ykGatherParams);
    }


    /**
     *
     * 根据不重名获取数据
     *
     *
     */
    @Transactional
    public List getYkGatherList( ) {

        return ykGatherDao.getYkGather();
    }

}